Skip to content

Incremental compiler fails when type parameter in trait is inferred #22651

Open
@Anghammar

Description

@Anghammar

Compiler version

3.6.3

Minimized code

File 1:

object IncrementalCompilerBug {
  import IncrementalCompilerBugOtherFile.Foo
  val x: Foo.InnerTrait = Foo.ExplicitTypeParameter
  val y: Foo.InnerTrait = Foo.TypeParameterFromInference
}

File 2:

object IncrementalCompilerBugOtherFile {
  trait SuperTrait {
    trait InnerTrait
    trait TraitWithTypeParameter[A](a: A) extends InnerTrait
  }
  object Foo extends SuperTrait {
    object ExplicitTypeParameter extends TraitWithTypeParameter[Int](3)
    object TypeParameterFromInference extends TraitWithTypeParameter(3)
  }
}

Output

Found:    IncrementalCompilerBugOtherFile.Foo.TypeParameterFromInference.type
Required: IncrementalCompilerBugOtherFile.Foo.InnerTrait [4:27]

Expectation

File 1 and 2 compiles just fine when you compile them both, e.g. when doing clean and compile in SBT. However, doing any irrelevant change in file 1 (like adding a comment or whitespace) without touching file 2 and recompiling with SBT will result in the compilation failure above at val y since TypeParameterFromInference extends TraitWithTypeParameter using type inference. In comparison, the compiler never have any problem with val x.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions