Skip to content

Type not found in derived class when extending trait with inner class type projection and F-bound #22508

Open
@readren

Description

@readren

Compiler version

Checked with 3.6.2 and 3.6.3

Minimized example

I posted this in stackoverflow and DmytroMitin suggested me to post it here also.

The following scala3 code compiles as expected:

	trait Product

	trait Provider[+P <: Product] {
		def provide: P
	}

	class Outer extends Provider[Outer#Inner] {
		override def provide: Inner = new Inner
		class Inner extends Product
	}

	class DerivedOuter extends Outer {
		override def provide: DerivedInner = new DerivedInner
		class DerivedInner extends this.Inner
	}

But if DerivedOuter also extended any type T[X] where X is a projection of a inner class of DerivedOuter, the compiler complains with a message that does not clarify the problem for me.

	class DerivedOuter extends Outer, Provider[DerivedOuter#DerivedInner] {
		override def provide: DerivedInner = new DerivedInner
		class DerivedInner extends this.Inner // <--- type `Inner` is not a member of `DerivedOuter`
	}

The problem arises when DerivedOuter also extends Provider[DerivedOuter#DerivedInner] (or any other trait with the same type argument).

Output Error/Warning message

The compiler complains at the line commented above saying:
type Inner is not a member of DerivedOuter

Why this Error/Warning was not helpful

The message was unhelpful because it gives no clue about which constraint, if any, causes the error.

Suggested improvement

I'm not even sure if the compiler should complain, let alone what the correct message should be if there should be any complaint at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:f-boundsarea:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions