// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package impl

import (
	

	
	
	ptag 
	
	
	
	
	
)

func ( *ExtensionInfo) () {
	 := .desc
	var  protoiface.MessageV1
	 := .ContainingMessage().FullName()
	if ,  := protoregistry.GlobalTypes.FindMessageByName();  != nil {
		// Create a new parent message and unwrap it if possible.
		 := .New().Interface()
		 := reflect.TypeOf()
		if ,  := .(unwrapper);  {
			 = reflect.TypeOf(.protoUnwrap())
		}

		// Check whether the message implements the legacy v1 Message interface.
		 := reflect.Zero().Interface()
		if ,  := .(protoiface.MessageV1);  {
			 = 
		}
	}

	// Determine the v1 extension type, which is unfortunately not the same as
	// the v2 ExtensionType.GoType.
	 := .goType
	switch .Kind() {
	case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String:
		 = reflect.PtrTo() // T -> *T for singular scalar fields
	}

	// Reconstruct the legacy enum full name.
	var  string
	if .Kind() == protoreflect.EnumKind {
		 = legacyEnumName(.Enum())
	}

	// Derive the proto file that the extension was declared within.
	var  string
	if  := .ParentFile();  != nil {
		 = .Path()
	}

	// For MessageSet extensions, the name used is the parent message.
	 := .FullName()
	if messageset.IsMessageSetExtension() {
		 = .Parent()
	}

	.ExtendedType = 
	.ExtensionType = reflect.Zero().Interface()
	.Field = int32(.Number())
	.Name = string()
	.Tag = ptag.Marshal(, )
	.Filename = 
}

// initFromLegacy initializes an ExtensionInfo from
// the contents of the deprecated exported fields of the type.
func ( *ExtensionInfo) () {
	// The v1 API returns "type incomplete" descriptors where only the
	// field number is specified. In such a case, use a placeholder.
	if .ExtendedType == nil || .ExtensionType == nil {
		 := placeholderExtension{
			name:   protoreflect.FullName(.Name),
			number: protoreflect.FieldNumber(.Field),
		}
		.desc = extensionTypeDescriptor{, }
		return
	}

	// Resolve enum or message dependencies.
	var  protoreflect.EnumDescriptor
	var  protoreflect.MessageDescriptor
	 := reflect.TypeOf(.ExtensionType)
	 := .Kind() == reflect.Ptr && .Elem().Kind() != reflect.Struct
	 := .Kind() == reflect.Slice && .Elem().Kind() != reflect.Uint8
	if  ||  {
		 = .Elem()
	}
	switch v := reflect.Zero().Interface().(type) {
	case protoreflect.Enum:
		 = .Descriptor()
	case enumV1:
		 = LegacyLoadEnumDesc()
	case protoreflect.ProtoMessage:
		 = .ProtoReflect().Descriptor()
	case messageV1:
		 = LegacyLoadMessageDesc()
	}

	// Derive basic field information from the struct tag.
	var  protoreflect.EnumValueDescriptors
	if  != nil {
		 = .Values()
	}
	 := ptag.Unmarshal(.Tag, , ).(*filedesc.Field)

	// Construct a v2 ExtensionType.
	 := &filedesc.Extension{L2: new(filedesc.ExtensionL2)}
	.L0.ParentFile = filedesc.SurrogateProto2
	.L0.FullName = protoreflect.FullName(.Name)
	.L1.Number = protoreflect.FieldNumber(.Field)
	.L1.Cardinality = .L1.Cardinality
	.L1.Kind = .L1.Kind
	.L2.IsPacked = .L1.IsPacked
	.L2.Default = .L1.Default
	.L1.Extendee = Export{}.MessageDescriptorOf(.ExtendedType)
	.L2.Enum = 
	.L2.Message = 

	// Derive real extension field name for MessageSets.
	if messageset.IsMessageSet(.L1.Extendee) && .FullName() == .L0.FullName {
		.L0.FullName = .L0.FullName.Append(messageset.ExtensionName)
	}

	 := reflect.TypeOf(.ExtensionType)
	if  {
		 = .Elem()
	}
	.goType = 
	.desc = extensionTypeDescriptor{, }
}

type placeholderExtension struct {
	name   protoreflect.FullName
	number protoreflect.FieldNumber
}

func ( placeholderExtension) () protoreflect.FileDescriptor            { return nil }
func ( placeholderExtension) () protoreflect.Descriptor                    { return nil }
func ( placeholderExtension) () int                                         { return 0 }
func ( placeholderExtension) () protoreflect.Syntax                        { return 0 }
func ( placeholderExtension) () protoreflect.Name                            { return .name.Name() }
func ( placeholderExtension) () protoreflect.FullName                    { return .name }
func ( placeholderExtension) () bool                                { return true }
func ( placeholderExtension) () protoreflect.ProtoMessage                 { return descopts.Field }
func ( placeholderExtension) () protoreflect.FieldNumber                   { return .number }
func ( placeholderExtension) () protoreflect.Cardinality              { return 0 }
func ( placeholderExtension) () protoreflect.Kind                            { return 0 }
func ( placeholderExtension) () bool                                  { return false }
func ( placeholderExtension) () string                                   { return "[" + string(.name) + "]" }
func ( placeholderExtension) () string                                   { return "[" + string(.name) + "]" }
func ( placeholderExtension) () bool                                  { return false }
func ( placeholderExtension) () bool                           { return false }
func ( placeholderExtension) () bool                                  { return true }
func ( placeholderExtension) () bool                                       { return false }
func ( placeholderExtension) () bool                                     { return false }
func ( placeholderExtension) () bool                                       { return false }
func ( placeholderExtension) () bool                                        { return false }
func ( placeholderExtension) () protoreflect.FieldDescriptor               { return nil }
func ( placeholderExtension) () protoreflect.FieldDescriptor             { return nil }
func ( placeholderExtension) () bool                                   { return false }
func ( placeholderExtension) () protoreflect.Value                        { return protoreflect.Value{} }
func ( placeholderExtension) () protoreflect.EnumValueDescriptor { return nil }
func ( placeholderExtension) () protoreflect.OneofDescriptor      { return nil }
func ( placeholderExtension) () protoreflect.MessageDescriptor  { return nil }
func ( placeholderExtension) () protoreflect.EnumDescriptor                  { return nil }
func ( placeholderExtension) () protoreflect.MessageDescriptor            { return nil }
func ( placeholderExtension) (protoreflect.FieldDescriptor)             { return }
func ( placeholderExtension) (pragma.DoNotImplement)                { return }