Skip to content

Inlining still breaks type checking #11924

@LPTK

Description

@LPTK

Compiler version

3.0.0-RC2-bin-20210325-ab2664f-NIGHTLY

Problem

It is not enough to special-case Nothing (type-ascribing only trees of this type as in #11917). In principle, all inlined parameters may require a type annotation. This is because removing type annotations in Scala can break type checking, as subtyping is not transitive.

Minimized code

type A
class B { def foo = 0 }
trait Ev { type T >: A <: B }

inline  // commenting this fixes the error
def test(ev: Ev)(x: ev.T): Int = x.foo

def trial(ev: Ev, a: A) = {
  test(ev)(a)  // foo cannot be accessed as a member of (a : A) from module class main$package$.
}

Expectation

If it type-checks without inline, it should type-check with inline too. In particular, I assume that non-transparent inline is not supposed to interfere with type checking in any way. Is that a correct assumption?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions