@@ -477,7 +477,15 @@ func (t *rawType) underlying() *rawType {
477
477
return t
478
478
}
479
479
480
+ func (t * rawType ) ptrtag () uintptr {
481
+ return uintptr (unsafe .Pointer (t )) & 0b11
482
+ }
483
+
480
484
func (t * rawType ) isNamed () bool {
485
+ if tag := t .ptrtag (); tag != 0 {
486
+ return false
487
+ }
488
+
481
489
return t .meta & flagNamed != 0
482
490
}
483
491
@@ -502,9 +510,13 @@ func pointerTo(t *rawType) *rawType {
502
510
503
511
switch t .Kind () {
504
512
case Pointer :
513
+ if tag := t .ptrtag (); tag < 3 {
514
+ return (* rawType )(unsafe .Add (unsafe .Pointer (t ), 1 ))
515
+ }
516
+
505
517
// TODO(dgryski): This is blocking https://github.com/tinygo-org/tinygo/issues/3131
506
518
// We need to be able to create types that match existing types to prevent typecode equality.
507
- panic ("reflect: cannot make **T type" )
519
+ panic ("reflect: cannot make ***** T type" )
508
520
case Struct :
509
521
return (* structType )(unsafe .Pointer (t )).ptrTo
510
522
default :
@@ -581,6 +593,11 @@ func (t *rawType) Kind() Kind {
581
593
if t == nil {
582
594
return Invalid
583
595
}
596
+
597
+ if tag := t .ptrtag (); tag != 0 {
598
+ return Pointer
599
+ }
600
+
584
601
return Kind (t .meta & kindMask )
585
602
}
586
603
@@ -591,6 +608,10 @@ func (t *rawType) Elem() Type {
591
608
}
592
609
593
610
func (t * rawType ) elem () * rawType {
611
+ if tag := t .ptrtag (); tag != 0 {
612
+ return (* rawType )(unsafe .Add (unsafe .Pointer (t ), - 1 ))
613
+ }
614
+
594
615
underlying := t .underlying ()
595
616
switch underlying .Kind () {
596
617
case Pointer :
0 commit comments