Skip to content

cmd/compile: pointer to concrete type doesn't satisfy generic type method set #48512

@DmitriyMV

Description

@DmitriyMV

This code:

package main

import "fmt"

type Fooer interface{ Foo() }

type FooGetter[F Fooer] interface{ GetFooer() F }

type A struct{}

func (A) GetFooer() B { return B{} }

type B struct{}

func (B) Foo() {}

func fun[F Fooer, FG FooGetter[F]](a *FG) F {
	return a.GetFooer()
}

func main() {
	fmt.Printf("%T", fun[B, A](&A{}))
}

works on playground, but doesn't on latest tip. I suspect this is correct behavior since simplified version doesn't compile either on go2go playground. But then, why does go2go permits this code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions