Skip to content

gc compiler error: private methods can leak through interfaces #1550

@griesemer

Description

@griesemer
Given an imported interface with a private method, a variable of that imported interface
type can be assigned to a local variable with a local interface type of the same
structure through the use of a type assertion. This makes it possible to call a private
method in another package.

The attached files document and illustrate the problem. To execute: copy the files p.go
and main.go into a new directory and run:

6g p.go && 6g main.go && 6l main.6 && 6.out

The output is:

main.Implementation.private()
p.Implementation.private()

but in fact it should not compile.

Attachments:

  1. p.go (187 bytes)
  2. main.go (1030 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions