Skip to content

Conversation

@neko-kai
Copy link
Contributor

When creating anonymous classes with new T {} where T is a type alias like type T[X] = SomeClass[X], the compiler was failing to infer type parameters, resulting in "is not a class type" errors.

The fix adds special handling for HKTypeLambda types in both Typer and Namer to create synthetic constructor applications for type parameter inference, similar to how class parents are handled.

When creating anonymous classes with `new T {}` where T is a type alias
like `type T[X] = SomeClass[X]`, the compiler was failing to infer type
parameters, resulting in "is not a class type" errors.

The fix adds special handling for HKTypeLambda types in both Typer and
Namer to create synthetic constructor applications for type parameter
inference, similar to how class parents are handled.
*/
def typedNewTemplateParent(tree: untpd.Tree, pt: Type)(using Context): Tree =
// First type with AnyTypeConstructorProto to check if it's a HKTypeLambda
val parentTpt = typedType(tree, AnyTypeConstructorProto)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure myself whether this is a great idea performance-wise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to avoid retyping in next commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants