Skip to content

Capture checking type mismatch between types that are reported to be the same #23027

Closed
@05st

Description

@05st

Compiler version

3.7.0-RC1

Minimized code

import language.experimental.captureChecking

trait Test {
    def foo(x: Test): Test =
        Test.bar
        ???
}

object Test {
    val _bar: Any => Any = identity
    def bar[T] = _bar.asInstanceOf[T => T]
}

If we change this line it compiles fine:

    def bar[T] = _bar.asInstanceOf//[T => T]

It also compiles fine if we disable capture checking (i.e. remove the captureChecking import).

Minimized from Future

Output

[error] -- [E007] Type Mismatch Error
[error] 11 |    def bar[T] = _bar.asInstanceOf[T => T]
[error]    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |             Found:    T => T
[error]    |             Required: T => T
[error]    |
[error]    |             Note that the expected type T => T
[error]    |             is the previously inferred result type of method bar
[error]    |             which is also the type seen in separately compiled sources.
[error]    |             The new inferred type T => T
[error]    |             must conform to this type.

Expectation

The type mismatch seems to be caused by some hidden difference in the types which is not being reported in the error. The error message should show this difference.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions