Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:49:10+00:00 2026-06-07T08:49:10+00:00

I have some Scala code I cannot get to compile, and I simplified it

  • 0

I have some Scala code I cannot get to compile, and I simplified it down to what appears to be the essence of the problem.

class Inner[T] {
  class Value
  val values = IndexedSeq.empty[Value]
}

class Outer[T] {
  def inner = new Inner[T]
}

object TestApp {
  def main(args: Array[String]) {
    val outer: Outer[_] = null
    val values = outer.inner.values
    values(0)
  }
}

I am using 2.9.1.final

$ scalac test.scala 
test.scala:14: error: ambiguous reference to overloaded definition,
both method apply in trait SeqLike of type ((idx: Int)Inner[_$1]#Value) forSome { type _$1 }
and  method apply in trait Function1 of type ((v1: Int)Inner[_$1]#Value) forSome { type _$1; type _$1; type _$1 }
match argument types (Int)
    values(0)
    ^
one error found

I am able to make the compilation error go away if I do any of the following:

  • Remove inner classes (IndexedSeq.empty[String] instead of IndexedSeq.empty[Value])
  • Remove existential types (Outer[String] instead of Outer[_])
  • Remove IndexedSeq.apply (values.head instead of values(0))
  • Change def inner to val inner (this is the most puzzling one)

Unfortunately in my use case, I can’t change any of those (it’s not evident why in this small example, but the actual code relies on them being that way). Am I doing something forbidden, or is this a limitation of the compiler?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:49:13+00:00Added an answer on June 7, 2026 at 8:49 am

    Probably a limitation since it seems fine in 2.10.0-M4.

    Of course it gives a NullPointer though since outer is set to null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to write some code in Scala to read a file
Say I have some Scala code like this: // Outputs 1, 4, 9, 16,
I have some mutable scala code that I am trying to rewrite in a
I have some Scala code that does something nifty with two different versions of
For a homework assignment I wrote some scala code in which I have the
I have some Java code which I'm translating to Scala. The code consists of
I have some Scala code roughly analogous to this: object Foo { val thingA
i have some problem in scala to resolve implicit values, and i have the
I have some problem to find oop information about my problem in scala, peraphs
I think I have implemented some of my code wrong. I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.