Skip to content

"cannot infer type; expected type <?> is not fully defined" for structural calls #9404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sjrd opened this issue Jul 21, 2020 · 0 comments
Closed
Assignees

Comments

@sjrd
Copy link
Member

sjrd commented Jul 21, 2020

Minimized code

import scala.reflect.Selectable.reflectiveSelectable

object Test {
  def main(args: Array[String]): Unit = {
    class Foo {
      def makeInt: Int = 5
      def testInt(x: Int): Unit = assert(5 == x)

      def makeRef: Option[String] = Some("hi")
      def testRef(x: Option[String]): Unit = assert(Some("hi") == x)
    }

    def test(foo: {
      def makeInt: Int
      def testInt(x: Int): Unit
      def makeRef: Option[String]
      def testRef(x: Option[String]): Unit
    }): Unit = {
      foo.testInt(foo.makeInt)
               //            ^
               // cannot infer type; expected type <?> is not fully defined
      foo.testRef(foo.makeRef)
               //            ^
               // cannot infer type; expected type <?> is not fully defined
    }

    test(new Foo)
  }
}

Output

-- Error: tests/run/hello.scala:24:29 ------------------------------------------
24 |      foo.testInt(foo.makeInt)
   |                             ^
   |               cannot infer type; expected type <?> is not fully defined
1 error found

(if we comment that line, the same error appears on the next line)

Expectation

All types are completely defined here, so I expect that there's nothing to be inferred, and therefore the "cannot infer type" error message doesn't make sense to me. I expect this code to compile and successfully run.

@sjrd sjrd added the itype:bug label Jul 21, 2020
@sjrd sjrd closed this as completed in 46c63e5 Jul 27, 2020
sjrd added a commit that referenced this issue Jul 27, 2020
Fix #9404: Make sure to keep arguments of structural calls typed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants