Skip to content
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

spurious type error applying a default parameter to parameter of type A.B of constructor A #4524

Closed
scabug opened this issue Apr 28, 2011 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Apr 28, 2011

=== What steps will reproduce the problem? ===

scala> object test {
     |   import A._
     |   class A(b: B = new A.B())
     |   object A {
     |     class B
     |     new A() //  found   : test.A#B, required: test.A.B
     |   }
     | }
<console>:12: error: type mismatch;
 found   : test.A#B
 required: test.A.B
Error occurred in an application involving default arguments.
           new A() //  found   : test.A#B, required: test.A.B
           ^

=== What is the expected behavior? ===

scala> object test {
     |   class A(b: A.B = new A.B())
     |   object A {
     |     class B
     |     new A() // okay
     |   }
     | }
defined module test

scala>

scala> object test {
     |   import A._
     |   class A(b: B)
     |   object A {
     |     class B
     |     new A(new B()) // okay
     |   }
     | }
defined module test

scala>

scala> object test {
     |   import C._
     |   class A(b: B = new C.B())
     |   object C {
     |     class B
     |     new A() //  okay
     |   }
     | }
defined module test

It seems to need the combination of the companion object and an import to trigger the problem.

=== What versions of the following are you using? ===

  • Scala: 2.8.1, 2.9.0.RC1
@scabug
Copy link
Author

scabug commented Apr 28, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4524?orig=1
Reporter: @retronym

@scabug
Copy link
Author

scabug commented Apr 28, 2011

@magarciaEPFL said:

[[syntax trees at end of typer]]// Scala source: bt4.scala
package <empty> {
  final object test extends System.Object with ScalaObject {
    def this(): object test = {
      test.super.this();
      ()
    };
    import test.this.A._;
    class A extends System.Object with ScalaObject {
      <paramaccessor> private[this] val b: test.A.B = _;
      def this(b: test.A.B = new test.this.A.B()): test.A = {
        A.super.this();
        ()
      }
    };
    final object A extends System.Object with ScalaObject {
      def this(): object test.A = {
        A.super.this();
        ()
      };
      class B extends System.Object with ScalaObject {
        def this(): test.A.B = {
          B.super.this();
          ()
        }
      };
      new test.this.A(test.this.A.<error: method init$$default$$1>);
      <synthetic> def init$$default$$1: test.A.B @scala.annotation.unchecked.uncheckedVariance = new test.this.A.B()
    }
  }
}

one error found

@scabug
Copy link
Author

scabug commented May 5, 2011

@lrytz said:
(In r24888) close #4524 and close #4425, review by odersky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants