diff --git a/src/cmd/compile/internal/types2/issues_test.go b/src/cmd/compile/internal/types2/issues_test.go
index 20e3f52facd9deb4f3f38ca8aec21cf6fd53f728..b339def7354e28b319c70452516492e6d938c78f 100644
--- a/src/cmd/compile/internal/types2/issues_test.go
+++ b/src/cmd/compile/internal/types2/issues_test.go
@@ -1121,3 +1121,23 @@ func f(x int) {
 		t.Errorf("got: %s want: %s", got, want)
 	}
 }
+
+func TestIssue68877(t *testing.T) {
+	const src = `
+package p
+
+type (
+	S struct{}
+	A = S
+	T A
+)`
+
+	conf := Config{EnableAlias: true}
+	pkg := mustTypecheck(src, &conf, nil)
+	T := pkg.Scope().Lookup("T").(*TypeName)
+	got := T.String() // this must not panic (was issue)
+	const want = "type p.T struct{}"
+	if got != want {
+		t.Errorf("got %s, want %s", got, want)
+	}
+}
diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go
index 241371b72fea4d19cb608b9c5ec6fb74361a1320..92dedf51d568a63d009b3293b66b152bfb69ef31 100644
--- a/src/cmd/compile/internal/types2/named.go
+++ b/src/cmd/compile/internal/types2/named.go
@@ -282,7 +282,7 @@ func (t *Named) cleanup() {
 		if t.TypeArgs().Len() == 0 {
 			panic("nil underlying")
 		}
-	case *Named:
+	case *Named, *Alias:
 		t.under() // t.under may add entries to check.cleaners
 	}
 	t.check = nil
diff --git a/src/go/types/issues_test.go b/src/go/types/issues_test.go
index 3f459d3883017efcd4e78d482948588376d43e95..da0c0c1255b63ef4b084f6bb69d8970784f6b48c 100644
--- a/src/go/types/issues_test.go
+++ b/src/go/types/issues_test.go
@@ -1131,3 +1131,23 @@ func f(x int) {
 		t.Errorf("got: %s want: %s", got, want)
 	}
 }
+
+func TestIssue68877(t *testing.T) {
+	const src = `
+package p
+
+type (
+	S struct{}
+	A = S
+	T A
+)`
+
+	t.Setenv("GODEBUG", "gotypesalias=1")
+	pkg := mustTypecheck(src, nil, nil)
+	T := pkg.Scope().Lookup("T").(*TypeName)
+	got := T.String() // this must not panic (was issue)
+	const want = "type p.T struct{}"
+	if got != want {
+		t.Errorf("got %s, want %s", got, want)
+	}
+}
diff --git a/src/go/types/named.go b/src/go/types/named.go
index 316cdc9bba41ff3ddd26dbcbf86319379ad89676..21d0f4f59f838893c63b06bba1b996a37cc5db2f 100644
--- a/src/go/types/named.go
+++ b/src/go/types/named.go
@@ -285,7 +285,7 @@ func (t *Named) cleanup() {
 		if t.TypeArgs().Len() == 0 {
 			panic("nil underlying")
 		}
-	case *Named:
+	case *Named, *Alias:
 		t.under() // t.under may add entries to check.cleaners
 	}
 	t.check = nil