Skip to content

Incremental compilation fails when match types and implicits are involved. #22684

Open
@FrancisToth

Description

@FrancisToth

We've found an issue involving match types and incremental compilation which can be reproduced with 3.5.2 and 3.3.5, but not with 3.6.3.

Compiler version

3.5.2 and 3.3.5

Minimized code

Given the following definitions:

package examples.draft

object library:
  trait Extension[A]:
    def doSomething(): Unit

  trait Companion[A]:
    given Extension[A] with
      def doSomething(): Unit = ()

  type NewType[A] = A match
    case String => Companion[A]

object definitions:
  import library.*
  opaque type Acronym = String
  object Acronym extends NewType[Acronym]

and then another file where the previous definitions are used:

package examples.draft2

import examples.draft.*

object Foo extends App:
  import definitions.*
  import library.*
  val x = summon[Extension[Acronym]] // this fails if definition file is not recompiled first

At first, the compilation seems to work, but the compiler throws an error whenever we modify the second file after a clean build. If we modify the definitions to:

object definitions:
  import library.*
  opaque type Acronym = String
  // object Acronym extends NewType[Acronym]
  object Acronym extends Companion[Acronym]

then incremental compilation succeeds. It seems the issue comes from the match type.

Output

This is the error thrown during incremental compilation:

No given instance of type examples.draft.library.Extension[examples.draft.definitions.Acronym] was found for parameter x of method summon in object Predef

Expectation

Going from a match type to whatever it's evaluated to should be transparent.

Thank you in advance for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:incremental-compilationitype:bugstat:fixed in nextThe issue was fixed in Next and only still applies to LTS.stat:needs bisectionNeed to use nightly builds and git bisect to find out the commit where this issue was introduced

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions