Skip to content

Class parameterization with an abstract projection type is broken by its instantiation. #11996

@noresttherein

Description

@noresttherein

reproduction steps

using Scala 2.13.1, 2.13.2

	trait Abstract {
		type Subject
	}

//	trait Concrete[S] extends Abstract { type Subject = S } //this works
	type Concrete[S] = Abstract { type Subject = S } //this doesn't
	
        trait Expr[T]

	trait Container[A <: Abstract] extends Expr[A#Subject] {

	}

	trait Derived[C <: Concrete[S], S] extends Container[C]

	trait Sub[C <: Concrete[S], S] extends Derived[C, S] {
		this: Expr[S]
	}

problem

The super cast in trait Sub does not compile.
Adding Expr[S] to the extend lists of Sub does not help. The problem is specific to both classes and traits extending a class/trait in the form of T[A] extends S[A#T] indirectly through a class/trait which narrows down the type parameter A to a type with a definition for T.

workaround:

instead of type narrowing, introduce a trait with the same signature which defines the member type as its type parameter.

Is this something likely to get fixed or will it have low priority at best due to Dotty not allowing it
in the first place?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions